<template>
  <div>
    <input @blur="flag = !flag" v-focus v-if="flag" type="text" />
    <button v-else @click="btn">{{ dd }}</button>
    <input ref="ab" type="button" @click="btn1" value="new Tag" />
  </div>
</template>
<script>
export default {
  name: '',
  model: {
    prop: 'dd'
  },
  props: {
    dd: {
      type: String
    }
  },
  data () {
    return {
      flag: false
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    btn () {
      this.flag = true
    },
    btn1 () {
      console.log(this.$refs.ab.type);
      this.$refs.ab.value = ''
      this.$refs.ab.type = 'text'
    }
  },
  directives: {
    focus: {
      inserted (el) {
        el.focus()
      }
    }
  },
  mounted () {
    this.$refs.ab.focus()
  }
}
</script>
<style lang='less'  scoped>
</style>
